//
//  JYJTabBarController.m
//  JYJ不得姐
//
//  Created by JYJ on 16/3/30.
//  Copyright © 2016年 baobeikeji. All rights reserved.
//

#import "TRATabBarController.h"
#import "HomeViewController.h"
#import "ActivityViewController.h"
#import "AmodifiedViewController.h"
#import "MineViewController.h"
#import "TRATabBar.h"
#import "TRANavigationController.h"


@interface TRATabBarController ()

@end

@implementation TRATabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加子控制器
    [self setupChildVc:[[HomeViewController alloc] init] image:@"icon_1" selectedImage:@"icon_2"];
    [self setupChildVc:[[AmodifiedViewController alloc] init] image:@"icon_3" selectedImage:@"icon_4"];
    [self setupChildVc:[[ActivityViewController alloc] init]image:@"icon_5" selectedImage:@"icon_6"];
    [self setupChildVc:[[MineViewController alloc] init]image:@"icon_7" selectedImage:@"icon_8"];
    
    // 更换tabBar
    [self setValue:[[TRATabBar alloc] init] forKey:@"tabBar"];
    
}

/**
 *  初始化控制器
 */
- (void)setupChildVc:(UIViewController *)vc image:(NSString *)image selectedImage:(NSString *)selectedImage {
    // 设置文字图片

    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    // 包装一个导航控制器，添加导航控制器为tabBarController的子控制器
    TRANavigationController *nav = [[TRANavigationController alloc]initWithRootViewController:vc];
    [self addChildViewController:nav];
    vc.tabBarItem.imageInsets = UIEdgeInsetsMake(7, 0, -7, 0);

}

@end
